package flc.ast.adapter;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyRatioBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class RatioAdapter extends StkProviderMultiAdapter<MyRatioBean> {

    public RatioAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(120));
        addItemProvider(new RatioProvider());
    }

    private class RatioProvider extends BaseItemProvider<MyRatioBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_ratio;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyRatioBean bean) {
            baseViewHolder.setText(R.id.tvRatioItemText, bean.getName());
            if (bean.isSelect()) {
                baseViewHolder.setBackgroundResource(R.id.tvRatioItemText, bean.getSelRes());
            } else {
                baseViewHolder.setBackgroundResource(R.id.tvRatioItemText, bean.getBgRes());
            }
        }
    }
}
